


import 'package:flutter/services.dart';

class ChatService {

  static const methodChannel = MethodChannel('hx_demo');


  ///测试账号数据
  static const String appKey = "1405230927107406#kefuchannelapp107850";
  static const String tenantId = "107850";
  static const String username = "test1";
  static const String password = "123456";
  static const String toUser = "kefuchannelimid_804915";


  //'1464230816068870#kefuchannelapp107568','107568'
  static Future<String?> init({
    String appKey = appKey,
    String tenantId = tenantId,
  }) async{
    return await methodChannel.invokeMethod<String>("init", <String, dynamic>{
      "appKey": appKey,
      "tenantId": tenantId,
    });
  }

  static Future<String?> register({
    String username = username,
    String password = password
  }) async{
    return await methodChannel.invokeMethod<String>("register", <String, dynamic>{
      "username": username,
      "password": password,
    });
  }


  static Future<String?> login({
    String username = username,
    String password = password
  }) async{
    return await methodChannel.invokeMethod<String>("login", <String, dynamic>{
      "username": username,
      "password": password,
    });
  }

  static Future sendTextMessage({
    required String text,
    String toUser = toUser
  }) async{
    return await methodChannel.invokeMethod("sendTextMessage", <String, dynamic>{
      "text": text,
      "toUser": toUser,
    });
  }


  static Future<List?> getMessages({
    required String msgId,
    String toUser = toUser
  }) async{
    return await methodChannel.invokeMethod<List>("getMessages", <String, dynamic>{
      "messageId": msgId,
      "serviceNumber": toUser,
    });
  }

}